]> git.r.bdr.sh - rbdr/super-polarity/blobdiff - Super Polarity/SuperPolarity.cs
Merge branch 'master' of github.com:benbeltran/super-polarity
[rbdr/super-polarity] / Super Polarity / SuperPolarity.cs
index b590079bf248f065530b48775c10083b6013c8c4..9311d5311c59c371127f151afdf51821761f9b60 100644 (file)
@@ -7,6 +7,8 @@ using Microsoft.Xna.Framework.Graphics;
 using Microsoft.Xna.Framework.Input;
 using Microsoft.Xna.Framework.Storage;
 using Microsoft.Xna.Framework.GamerServices;
+using Microsoft.Xna.Framework.Media;
+using Microsoft.Xna.Framework.Audio;
 using SuperPolarity;
 #endregion
 
@@ -17,16 +19,37 @@ namespace SuperPolarity
     /// </summary>
     public class SuperPolarity : Game
     {
-        public static GraphicsDeviceManager graphics;
+        public GraphicsDeviceManager graphics;
         SpriteBatch spriteBatch;
 
+        public static int OutlierBounds;
+
+        public Player Player;
+
+        Screen EntryScreen;
+
+        protected Song TitleSong;
+        protected Song GameSong;
+        protected SoundEffect GameOverSound;
+
         public SuperPolarity()
             : base()
         {
-            SuperPolarity.graphics = new GraphicsDeviceManager(this);
-            SuperPolarity.graphics.PreferMultiSampling = true;
+            graphics = new GraphicsDeviceManager(this);
+            Components.Add(new GamerServicesComponent(this));
+
+            graphics.PreferMultiSampling = true;
+            graphics.PreferredBackBufferWidth = 1280;
+            graphics.PreferredBackBufferHeight = 720;
+            graphics.ToggleFullScreen();
+
             Content.RootDirectory = "Content";
             ActorFactory.SetGame(this);
+            ParticleEffectFactory.SetGame(this);
+            ActorManager.SetGame(this);
+            ScreenManager.SetGame(this);
+
+            EntryScreen = (Screen)new TitleScreen(this);
         }
 
         /// <summary>
@@ -39,11 +62,18 @@ namespace SuperPolarity
         {
             base.Initialize();
 
-            InputController.RegisterEventForButton("changePolarity", Buttons.A);
-            InputController.RegisterEventForKey("changePolarity", Keys.Z);
+            InputController.RegisterEventForKey("fullScreenToggle", Keys.F11);
+            InputController.Bind("fullScreenToggle", HandleFullScreenToggle);
+
+            EntryScreen.Initialize();
+
+            OutlierBounds = 100;
+        }
 
-            InputController.RegisterEventForButton("shoot", Buttons.X);
-            InputController.RegisterEventForKey("shoot", Keys.X);
+        protected void HandleFullScreenToggle(float value)
+        {
+            graphics.ToggleFullScreen();
+            graphics.ApplyChanges();
         }
 
         /// <summary>
@@ -52,14 +82,17 @@ namespace SuperPolarity
         /// </summary>
         protected override void LoadContent()
         {
+
+            MediaPlayer.IsRepeating = true;
+            GameSong = Content.Load<Song>("Sound\\polaritytheme.wav");
+            GameOverSound = Content.Load<SoundEffect>("Sound\\gameover");
+
             // Create a new SpriteBatch, which can be used to draw textures.
             spriteBatch = new SpriteBatch(GraphicsDevice);
 
-            Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
+            ScreenManager.Push(EntryScreen);
 
-            ActorFactory.CreateShip(Ship.Polarity.Positive, new Vector2(200, 200));
-            ActorFactory.CreateShip(Ship.Polarity.Negative, new Vector2(400, 200));
-            ActorFactory.CreateMainShip(playerPosition);
+            Player = new Player(this);
         }
 
         /// <summary>
@@ -81,10 +114,9 @@ namespace SuperPolarity
             if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                 Exit();
 
-            // TODO: Add your update logic here
+            ScreenManager.Update(gameTime);
 
-            InputController.UpdateInput();
-            ActorManager.Update(gameTime);
+            Player.Update();
 
             base.Update(gameTime);
         }
@@ -99,11 +131,31 @@ namespace SuperPolarity
 
             spriteBatch.Begin();
 
-            ActorManager.Draw(spriteBatch);
+            ScreenManager.Draw(spriteBatch);
 
             spriteBatch.End();
 
             base.Draw(gameTime);
         }
+
+        public void PlaySong(string songName)
+        {
+            // temp stuff before media manager is in
+            if (songName == "game")
+            {
+                MediaPlayer.Play(GameSong);
+            }
+        }
+
+        public void GameOver()
+        {
+            var scoreScreen = new ScoreScreen(this);
+            scoreScreen.Initialize();
+
+            MediaPlayer.Stop();
+            GameOverSound.Play();
+            ScreenManager.Pop();
+            ScreenManager.Push(scoreScreen);
+        }
     }
 }